﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SH.Common.CommonReturn;
using SH.Customer.Application.IApplication.IEquities;

namespace SH.Customer.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EquitiesController : ControllerBase
    {
        private readonly IEquitiesApplication _equitiesApplication;

        public EquitiesController(IEquitiesApplication equitiesApplication)
        {
            _equitiesApplication = equitiesApplication;
        }

        /// <summary>
        /// 添加权益信息
        /// </summary>
        /// <param name="equitiesDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> EquitiesAdd(EquitiesDto equitiesDto)
        {
            var result = await _equitiesApplication.EquitiesAdd(equitiesDto);
            return Ok(result);
        }

        /// <summary>
        /// 获取权益信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetEquitiesList()
        {
            var list = await _equitiesApplication.GetListAsync();
            return Ok(list);
        }

        /// <summary>
        /// 删除权益信息
        /// </summary>
        /// <param name="eId"></param>
        /// <returns></returns>
        [HttpDelete]
        public IActionResult DeleteEquities(int eId)
        {
            var result = _equitiesApplication.DeleteEquities(eId);
            return Ok(result);
        }

        /// <summary>
        /// 获取权益详情信息
        /// </summary>
        /// <param name="eId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetEquitiesDelitalAsync(int eId)
        {
            var result = await _equitiesApplication.GetEquitiesDelitalAsync(eId);
            return Ok(result);
        }

        /// <summary>
        /// 修改权益信息
        /// </summary>
        /// <param name="updDto"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpdEquities(EquitesUpdDto updDto)
        {
            var result = _equitiesApplication.UpdEquities(updDto);
            return Ok(result);
        }
    }
}